﻿
using AutoMapper;
using Modules.Corp;
using Modules.Project;
using PmSoft;

namespace ManagementApi.Models.System.ProjectCorpWageAuth;

public class ProjectCorpWageAuthDto : Modules.ProjectCorpWageAuth
{
    #region 扩展属性
    public string ProjectName { get; set; }

    public string CorpName { get; set; }
    #endregion
}

public static partial class ProjectCorpWageAuthExceptions
{
    public static ProjectCorpWageAuthDto AsDto(this Modules.ProjectCorpWageAuth entity)
    {
        ProjectCorpWageAuthDto dto = new();
        var mapper = ServiceAccessor.GetService<IMapper>();
        mapper.Map(entity, dto);
        var corpService = ServiceAccessor.GetService<CorpService>();
        dto.CorpName = corpService.GetCorpInfo(entity.CorpId)?.Name ?? string.Empty;
        var projectService = ServiceAccessor.GetService<ProjectService>();
        dto.ProjectName = projectService.GetProjectInfo(entity.ProjectId)?.Name ?? string.Empty;
        return dto;
    }
}
